package com.admission.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

import com.admission.dao.AcademyDao;
import com.admission.model.Academy;

@Repository
@Transactional
public class AcademyManager {
	private AcademyDao academyDao;

	  @Autowired
		public void setAcademyDao(AcademyDao academyDao) {
			this.academyDao = academyDao;
		}
	    
	/**
	 * 通过id找唯一对象，无返回null
	 * 
	 * @param id
	 * @return
	 */
	public Academy getAcademyById(String id) {
		return academyDao.findUniqueBy("id", id);
	}
	
	/**
	 * 保存
	 * 
	 * @param Entity
	 * @return
	 */
	public void save(Academy entity) throws Exception{
		 entity.setState("1"); 
		 academyDao.save(entity);
	}
	/**
	 * 隐藏显示
	 * 
	 * @param Entity
	 * @return
	 */
	public void onCheck(Academy entity,String state) throws Exception{
		 entity.setState(state); 
		 academyDao.save(entity);
	}
	/**
	 * 通过filter查询结果
	 * 
	 * @param filters
	 * @return
	 */
	public List<Academy> getListByFilter(List<PropertyFilter> filters) {
		return academyDao.find(filters);
	}

	/**
	 * 通过filter查询结果
	 * 
	 * @param filters
	 * @return
	 */
	public Page<Academy> getPageByFilter(Page<Academy> page,List<PropertyFilter> filters) {
		return academyDao.findPage(page,filters);
	}
}
